# stage 1
FROM openjdk:8-jdk-alpine AS build

RUN apk add --no-cache maven

WORKDIR /app

COPY pom.xml ./
COPY src src

RUN mvn clean -U package -Dmaven.test.skip=true && \
    cp target/web-api*.jar target/web-api.jar


# stage 2
FROM openjdk:8-jdk-alpine

WORKDIR /data

COPY --from=build /app/target/web-api.jar /app/

ENV TZ Asia/Shanghai

# 时区
RUN apk add tzdata && cp /usr/share/zoneinfo/${TZ} /etc/localtime \
    && echo ${TZ} > /etc/timezone \
    && apk del tzdata

# 系统编码 (基础镜像已经设置)
#ENV LANG C.UTF-8

# JAVA_OPTS
ENV JAVA_OPTS="-Dspring.profiles.active=prod -Xms2g -Xmx2g"

CMD java ${JAVA_OPTS} -jar /app/web-api.jar
